import wepy from 'wepy'
export default class extends wepy.mixin {
    data = {
        addressInfo: null
    }
  
    methods = {
        async chooseAdress(){
            // 这里的chooseAdress为微信官方api
            var res = await wepy.chooseAdress().catch(err=>err)
            if (res.errMsg == 'chooseAddress:fail cancel') {
                return  wepy.baseToast('取消了选择收货地址')
            }
            wepy.baseToast('选择收货地址成功')
            wepy.setStorageSync('address',res)
            console.log(res);
            
        }
    }

    computed = {
        isHaveAddress() {
          if (this.addressInfo === null) {
            return false
          }
          return true
        }
    }

    onLoad() {
        // 在订单页面加载期间读取收货地址
        this.addressInfo = wepy.getStorageSync('address') || null
    }
    
}